package com.turing.manage.grade;

import java.sql.SQLException;
import java.sql.Types;
import java.util.List;
import java.util.Map;
import com.turing.dao.Dao;
import com.turing.dao.DaoImpl;

public class GradeService {
	
	Dao dao = new DaoImpl();
	


	public List<Map<String, Object>> queryByAll(String grade_id, String key) throws ClassNotFoundException, SQLException {
		 String sql = "select * from grade";

	        if (key == null) {
	            key = "";
	        }

	        if (grade_id == null) {
	            grade_id = "";
	        } else if (grade_id.equals("1")) {
	            sql = "select * from grade where grade_id=?";

	            return dao.executeQueryForList(sql,new int[]{Types.VARCHAR}, new Object[]{key});
	        } else if (grade_id.equals("2")) {
	            sql = "select * from grade where course_id IN(select course_id from course where course_name=?)";
	            return dao.executeQueryForList(sql,new int[]{Types.VARCHAR}, new Object[]{key});
	        } else if (grade_id.equals("3")) {
	            sql = "select * from grade where grade_minute_use=?";
	            return dao.executeQueryForList(sql,new int[]{Types.VARCHAR}, new Object[]{key});
	        }

	        return dao.executeQueryForList(sql);

	}
	
	
	

}
